package com.zhangye.test.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhangye.test.model.ProxyCompany;
import com.zhangye.test.service.ProxyCompanyService;

@Controller
@RequestMapping("api/proxyCompany")
public class ProxyCompanyApi {
	
	@Autowired
	private ProxyCompanyService proxyCompanyService;
	

	@ResponseBody
	@RequestMapping(value = "/getName")
	public ApiResult getName(Long id) {
		ApiResult result = new ApiResult();
		String where = " and id = " + id + " and status = 'on'";
		List<ProxyCompany> list = proxyCompanyService.selectWhere(where);
		if(list.size() > 0){
			ProxyCompany pc = list.get(0);
			result.data.put("name", pc.getName() + " © " + pc.getWechat());
			result.msg.status = 0;
			result.msg.desc = "获取成功";
		}else{
			result.msg.status = 1;
			result.msg.desc = "暂无数据";
		}
		return result;
	}

}
